package com.foreknow.eldclient.controller;

import com.foreknow.eldclient.po.Business;
import com.foreknow.eldclient.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@ResponseBody
@RequestMapping("BusinessController")
public class BusinessController {
    @Autowired
    private BusinessService BS;

    @RequestMapping("/getBusinessById")
    public Business getBusinessById(int businessId){
        return BS.getBusinessById(businessId);
    }

    @RequestMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(int orderTypeId){
        return  BS.listBusinessByOrderTypeId(orderTypeId);
    }

    @RequestMapping("/listAllBusiness")
    List<Business> listAllBusiness(){
        return BS.listAllBusiness();
    }

    @RequestMapping("/listBusinessBykeyword")
    public List<Business> listBusinessBykeyword(String keyword) throws Exception {
        return BS.listBusinessBykeyword(keyword);
    }

    @RequestMapping("/registerBusiness")
    public int registerBusiness(Business business) {
        return BS.registerBusiness(business);
    }

    @RequestMapping("/getBusinessByIdByPass")
    public Business getBusinessByIdByPass(String businessId, String password) {
        return BS.getBusinessByIdByPass(businessId,password);
    }

    @RequestMapping("/updateBusiness")
    public int updateBusiness(Business business) {
        return BS.updateBusiness(business);
    }

    @RequestMapping("/updateTotalSales")
    public int updateTotalSales(Integer orderId) throws Exception {
        return BS.updateTotalSales(orderId);
    }

    @RequestMapping("/sales_ranking")
    public List<Business> sales_ranking() {
        return BS.sales_ranking();
    }

    @RequestMapping("/getBusinessByFId")
    public Business getBusinessByFId(int foodId) {
        return BS.getBusinessByFId(foodId);
    }

    @RequestMapping("/getBusinessByFuzzy")
    public List<Business> getBusinessByFuzzy(String keyword) throws Exception {
        return BS.getBusinessByFuzzy(keyword);
    }

}
